package com.redis.server.cn.controller;

import com.redis.server.cn.commen.ActionResult;
import com.redis.server.cn.config.ActionCodeConfig;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.cloud.context.config.annotation.RefreshScope;

/**
 * 访问
 @RestController
 *
 * @author : njl
 * @created : 2018-04-02 22:31
 */
// 跨域支持
@CrossOrigin(origins = "*", methods = {RequestMethod.POST, RequestMethod.OPTIONS, RequestMethod.GET, RequestMethod.DELETE,RequestMethod.PUT})
// 允许配置文件刷新
@RefreshScope
public class RedisController {

    public  static final Logger LOGGER= LoggerFactory.getLogger(RedisController.class);

//    @Autowired
//    ActionCodeConfig actionCodeConfig;
//
//        @PostMapping(value = "/communitybasicinfo/car"  )
//    @ApiOperation(value = "新增车辆",notes = "新增车辆（xh 不填；clbh 不填；hphm 号牌号码 必填；pp 品牌 选填；cx 车型 选填；clbq 车辆标签 选填；" +
//            "xm 车主姓名 选填；sfz 车主身份证  选填；lxfs 联系方式  选填；rybh 人员编号  选填；ptbh 平台编号  必填《列表选择》； ylzd 扩展字段 不填；）")
//    public ActionResult  saveCarsService(@RequestBody CarsDto carsDto)throws Exception{
//        if(StringTools.isEmpty(carsDto.getHphm()) || StringTools.isEmpty(carsDto.getPtbh())){
//            throw  new Exception(" hphm和ptbh不能为空！");
//        }
//        ActionResult result=new ActionResult();
//        Object normalData=  carsBasicinfoService.saveCars(carsDto);
//        result.setResponseCode(actionCodeConfig.getSucceedCode());
//        result.setMessage(actionCodeConfig.getSucceedMessage());
//        result.setContent(normalData);
//        LOGGER.info("CarsBasicinfoController.saveCarsService 新增车辆信息 Result = " + result);
//        return result;
//    }




//    @Autowired
//    ActionCodeConfig actionCodeConfig;
//
//    @GetMapping(value = "/communitybasicinfo/car" )
//    @ApiOperation(value = "查询车辆",notes = "查询车辆（）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "xh", value = "序号", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "clbh", value = "车辆编号", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "hphm", value = "号牌号码", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "pp", value = "品牌", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "cx", value = "车型", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "clbq", value = "车辆标签，多个逗号隔开", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "xm", value = "车主姓名", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "sfz", value = "车主身份证号", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "lxfs", value = "联系方式", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "rybh", value = "人员编号", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "ptbh", value = "平台编号", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "keyword", value = "关键字(匹配：hphm,pp ,cx ,clbq,xm ,sfz,lxfs,rybh,ptbh)", required = false, paramType = "query"),
//            @ApiImplicitParam(name = "zt",value = "状态，1正常 0删除 默认正常 1" ,required = false,paramType = "query"),
//            @ApiImplicitParam(name = "begintime",value = "创建时间开始范围",required = false,paramType = "query"),
//            @ApiImplicitParam(name = "endtime",value = "创建时间截止范围",required = false,paramType = "query"),
//            @ApiImplicitParam(name = "page",value = "页数（默认1）",required = false,paramType = "query"),
//            @ApiImplicitParam(name = "size",value = "每页显示条数(默认10)",required = false,paramType = "query")
//    })
//    public ActionResult getCarsService(@RequestParam(name = "xh", required = false,defaultValue = "") String xh,
//                                       @RequestParam(name = "clbh", required = false,defaultValue = "") String clbh,
//                                       @RequestParam(name = "hphm", required = false,defaultValue = "") String hphm,
//                                       @RequestParam(name = "pp", required = false,defaultValue = "") String pp,
//                                       @RequestParam(name = "cx", required = false,defaultValue = "") String cx,
//                                       @RequestParam(name = "clbq", required = false,defaultValue = "") String clbq,
//                                       @RequestParam(name = "xm", required = false,defaultValue = "") String xm,
//                                       @RequestParam(name = "sfz", required = false,defaultValue = "") String sfz,
//                                       @RequestParam(name = "lxfs", required = false,defaultValue = "") String lxfs,
//                                       @RequestParam(name = "rybh", required = false,defaultValue = "") String rybh,
//                                       @RequestParam(name = "ptbh", required = false,defaultValue = "") String ptbh,
//                                       @RequestParam(name = "keyword", required = false,defaultValue = "") String keyword,
//                                       @RequestParam(name = "zt", required = false,defaultValue = "1") String zt,
//                                       @RequestParam(name = "begintime", required = false,defaultValue = "") String begintime,
//                                       @RequestParam(name = "endtime", required = false,defaultValue = "") String endtime,
//                                       @RequestParam(name = "page", required = false,defaultValue = "1") String page,
//                                       @RequestParam(name = "size", required = false,defaultValue = "10") String size){
//
//        Map<String,String> paraMap=new HashMap<>();
//        paraMap.put("xh",xh);
//        paraMap.put("hphm",hphm);
//        paraMap.put("clbh",clbh);
//        paraMap.put("pp",pp);
//        paraMap.put("cx",cx);
//        paraMap.put("clbq",clbq);
//        paraMap.put("xm",xm);
//        paraMap.put("sfz",sfz);
//        paraMap.put("lxfs",lxfs);
//        paraMap.put("rybh",rybh);
//        paraMap.put("ptbh",ptbh);
//        paraMap.put("keyword",keyword);
//        paraMap.put("zt",zt);
//        paraMap.put("begintime",begintime);
//        paraMap.put("endtime",endtime);
//        paraMap.put("pagenum",page);
//        paraMap.put("pagesize",size);
//        ActionResult result=new ActionResult();
//        Object normalData=  carsBasicinfoService.getCarsList(paraMap);
//        result.setResponseCode(actionCodeConfig.getSucceedCode());
//        result.setMessage(actionCodeConfig.getSucceedMessage());
//        result.setContent(normalData);
//        LOGGER.info("CarsBasicinfoController.getCarsService  查询小区车辆信息 Result = " + result);
//        return result;
//    }
//
//    @PostMapping(value = "/communitybasicinfo/car"  )
//    @ApiOperation(value = "新增车辆",notes = "新增车辆（xh 不填；clbh 不填；hphm 号牌号码 必填；pp 品牌 选填；cx 车型 选填；clbq 车辆标签 选填；" +
//            "xm 车主姓名 选填；sfz 车主身份证  选填；lxfs 联系方式  选填；rybh 人员编号  选填；ptbh 平台编号  必填《列表选择》； ylzd 扩展字段 不填；）")
//    public ActionResult  saveCarsService(@RequestBody CarsDto carsDto)throws Exception{
//        if(StringTools.isEmpty(carsDto.getHphm()) || StringTools.isEmpty(carsDto.getPtbh())){
//            throw  new Exception(" hphm和ptbh不能为空！");
//        }
//        ActionResult result=new ActionResult();
//        Object normalData=  carsBasicinfoService.saveCars(carsDto);
//        result.setResponseCode(actionCodeConfig.getSucceedCode());
//        result.setMessage(actionCodeConfig.getSucceedMessage());
//        result.setContent(normalData);
//        LOGGER.info("CarsBasicinfoController.saveCarsService 新增车辆信息 Result = " + result);
//        return result;
//    }
//
//    @PutMapping(value = "/communitybasicinfo/car"  )
//    @ApiOperation(value = "更新车辆",notes = "更新车辆 根据xh或 clbh更新（xh 选填；clbh 不填；hphm 号牌号码 选填pp 品牌 选填；cx 车型 选填；clbq 车辆标签 选填；" +
//            "xm 车主姓名 选填；sfz 车主身份证  选填；lxfs 联系方式  选填；rybh 人员编号  选填；ptbh 平台编号  选填《列表选择》； ylzd 扩展字段 不填；）")
//    public ActionResult  modifyCarsService(@RequestBody CarsDto carsDto)throws Exception{
//        if(StringTools.isEmpty(carsDto.getXh())  && StringTools.isEmpty(carsDto.getClbh())  ){
//            throw  new Exception(" 更新条件不能为空！");
//        }
//        ActionResult result=new ActionResult();
//        Object normalData=  carsBasicinfoService.chargeCars(carsDto);
//        result.setResponseCode(actionCodeConfig.getSucceedCode());
//        result.setMessage(actionCodeConfig.getSucceedMessage());
//        result.setContent(normalData);
//        LOGGER.info("CarsBasicinfoController.modifyCarsService 更新车辆信息 Result = " + result);
//        return result;
//    }
//
//
//    @DeleteMapping(value = "/communitybasicinfo/car"  )
//    @ApiOperation(value = "删除车辆",notes = "删除车辆（根据xh或clbh）")
//    public ActionResult  removeCarsService(@RequestBody Map<String,String> paraMap) throws Exception{
//        String xh=paraMap.get("xh");
//        String clbh=paraMap.get("clbh");
//
//        ActionResult result=new ActionResult();
//        if(StringTools.isEmpty(xh)  && StringTools.isEmpty(clbh)){
//            throw  new Exception(" 删除条件不能为空！");
//        }
//        Object normalData=  carsBasicinfoService.removeCars(xh,clbh);
//        result.setResponseCode(actionCodeConfig.getSucceedCode());
//        result.setMessage(actionCodeConfig.getSucceedMessage());
//        result.setContent(normalData);
//        LOGGER.info("CarsBasicinfoController.removeCarsService 删除车辆信息 Result = " + result);
//        return result;
//    }


}
